<?xml version="1.0" encoding="ISO-8859-1"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:s="http://jboss.com/products/seam/taglib"
  template="/WEB-INF/templates/template.xhtml"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich">
  
  <ui:define name="head">
  </ui:define>
<ui:define name="body">
 </ui:define>    
<ui:define name="editUser">
   <center >
    <br />
   <h:outputText value="ABM de usuarios"  styleClass="tituloabm"/>
	<br />
	<br />
   <div class ="divabm">
	<h:form  id = "saveuserform" rendered="#{appUser.userLogin != null}">
    	<h:panelGrid columns="1">
    		<h:outputText value="#{messages.edituserhelp}" styleClass="outputcommon"/>
    	</h:panelGrid>
    	<h:panelGrid columns= "3">
    		<h:outputText value="#{messages.editusername}" styleClass="outputcommonbold"/>
    		<h:inputText id="username" value="#{admUserCtrl.userSelected.userName}" />
    		<h:message for="username" style="color:red" />
    		<h:outputText value="#{messages.password}" styleClass="outputcommonbold"/>
    		<h:inputSecret value="#{admUserCtrl.userSelected.keyWord}" />
    		<h:outputText value="" />
    		<h:outputText value="#{messages.confirmpassword}" styleClass="outputcommonbold" />
    		<h:inputSecret id="password" value="#{admUserCtrl.confirmPassword}" />
    		<h:message for="password" style="color:red" />
    		<h:outputText value="#{messages.editname}" styleClass="outputcommonbold"/>
    		<h:inputText id = "nombre" value="#{admUserCtrl.userSelected.nombre}" />
    		<h:message for="nombre" style="color:red" />
    		<h:outputText value="#{messages.editapellido}" styleClass="outputcommonbold" />
    		<h:inputText id= "apellido" value="#{admUserCtrl.userSelected.apellido}"  />
    		<h:message for="apellido" style="color:red" />
    	</h:panelGrid>
    	<h:panelGrid columns= "2">	
    		<h:outputText value="#{messages.editprofile}" styleClass="outputcommonbold"/>
    		  <h:selectOneMenu value="#{admUserCtrl.userSelected.perfil}" converter="#{profileadapter.converter}" >
    			<f:selectItems value="#{profileadapter.items}"/>
    		</h:selectOneMenu>
    		<h:outputText value="#{messages.editactive}" styleClass="outputcommonbold"/>
    		<h:selectBooleanCheckbox value="#{admUserCtrl.userSelected.activo}" />
    	</h:panelGrid>
    	<br />
		<br />
    	<h:panelGrid columns="3">
    			<h:commandLink action="admin-users.jsf" styleClass="commandLink">
    			  	<h:commandButton action="#{admUserCtrl.clearData}" value ="Volver" styleClass="volverbutton" >
    			  		<f:ajax  event="click" reRender="saveuserform" execute="@form" immediate="true" />
    			  	</h:commandButton>
	   		    </h:commandLink>
	   		    <h:commandButton action="#{admUserCtrl.removeUser}" value="Eliminar" styleClass="eliminarbutton"  rendered="#{admUserCtrl.userSelected.id != null}"/>
	   		    <h:commandButton action="#{admUserCtrl.saveUser}" value ="Guardar" styleClass="guardarbutton"  />
    	</h:panelGrid>
    	<h:panelGrid columns="1">
    			<h:outputText id="savesuccessmsg" value="#{messages.savesuccess}" rendered = "#{admUserCtrl.saveSuccess}"  style="FONT-WEIGHT: bold; COLOR: #ff0000;"/>
    			<h:outputText id="deletesuccessmsg" value="#{messages.deletesuccess}" rendered = "#{admUserCtrl.deleteSuccess}"  style="FONT-WEIGHT: bold; COLOR: #ff0000;"/>
    	</h:panelGrid>
    </h:form>
	
	</div>
	</center>
	</ui:define>

 </ui:composition>

